package cn.hx.fristgame;

import java.awt.*;

/**
 * 游戏中物体的父类
 */
public class gameObj {
     Image img;
     double x,y;
     int speed = 5;
     int width,height;

     public void drawSelf(Graphics g){
         g.drawImage(img,(int)x,(int)y,null);
     }

    public gameObj(Image img, double x, double y, int speed, int width, int height) {
        this.img = img;
        this.x = x;
        this.y = y;
        this.speed = speed;
        this.width = width;
        this.height = height;
    }

    public gameObj(Image img, double x, double y) {
        this.img = img;
        this.x = x;
        this.y = y;
    }

    public gameObj(){

    }
    public Rectangle getRectangle(){    //返回物体所在的矩形，用于碰撞检测
         return new Rectangle((int)x,(int)y,width,height);
    }
}
